<?php
//phpinfo();
echo 'ddd';
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('html_errors', 1);

function dump($variable){
	echo"<pre>";
	print_r($variable);
	echo"</pre>";
}
//dump(__DIR__);
echo 'as';

echo defined('__DIR__');
 $iPos = strrpos(__FILE__, "/");
define('LIBRARY',substr(__FILE__, 0, $iPos) . "/library");
dump(LIBRARY);

if(!defined('__DIR__')) {
	echo 'niema';
    $iPos = strrpos(__FILE__, "/");
    define("__DIR__", substr(__FILE__, 0, $iPos) . "/library");
} 



//define("__DIR__", substr(__FILE__, 0, $iPos) . "/library");

dump(__DIR__);

echo defined('__DIR__');

$modules = array();
// *************************************************
$modules['modul']['name'] = 'modul';



$langSetup['pl']['code'] = 'pl';
$langSetup['pl']['newsHomepage'] = 2;
$langSetup['pl']['artHomepage'] = 1;
//domyslny j�zyk
define('DEFAULT_LANG','pl');
define('ADMIN_LANG','pl');

//domyslny modul ladowany zawsze
define('DEFAULT_MODULE','article');  

define(DIRECTORY_SEPARATOR,'/');
require_once 'library/autoloader.php';
//require_once'library/Smarty/Smarty.class.php';
//$smarty = new Smarty;


define('DB_HOST', 'localhost');
define('DB_NAME', 'fotobank');
define('DB_USER', 'root');
define('DB_PASSWORD', 'root');



$classLoader = new SplClassLoader();
$classLoader->register();

//print_r($classLoade;

/*
$registry = new Zend_Registry(array(), ArrayObject::ARRAY_AS_PROPS);
Zend_Registry::setInstance($registry);
$registry->tree = 'apple';

$registry->loader = $classLoader;
*/
$router = new Router_Router();

$router->routerr();

//dump($router);

//$registry->router = 'aaa';


//$a =new CMD_KlasaInna;

//$b = new CMS_Klasa;

//$c = new CMD_cd_Jeszczeklasa();

//$value = 'wartosc';


$registry = Registry_Registry::singleton();

$registry->storeObject('a','wartosc a');

echo $registry->getObject('a');

print_r(Registry_Registry::singleton());

//$art = new Article_Article();

$artykuly = Article_Article::singleton();

dump($artykuly);

//$artykuly->getList();

//$router->widok['Article']['list'] = $artykuly->getView();

//$a = Registry_Registry::getObject('action');
$a = $router->action;
$r = $router->module;

echo $r;

//Article_Article::$a;
//$r = Registry_Registry::getObject('module');

echo"<br>wywolujemy modul $r z akcja $a <br>";	
/////////tututututututututut
//$art = $r::singleton();
//$art = Article_Article::singleton();
///////////////////

$art = new $r;

$met = get_class_methods($art);
dump($met);


$art->$a();

dump($art);

//$r::$a();

		
//$db = new Db();



//dump($d);


	$router->widok[$router->module] = array_merge($router->widok[$router->module], $art->getView());	





/*
$classLoader->unregister();
require(LIBRARY.'/Smarty/Smarty.class.php');
$smarty = new Smarty;
$classLoader->register();
$smarty->setConfigDir('./configuration');
dump($router->getWidok());
$smarty->assign('widok',$router->getWidok());
$smarty->display('index.tpl');
echo"srrrru";
*/




//$smarty->testInstall();

//
/*
$classLoader->unregister();
require('lib/Smarty/Smarty.class.php');
$smarty = new Smarty;
$classLoader->register();
*/

//$c = new CMD_cd_Jeszczeklasa();
/*
$smarty->debugging = false;
$smarty->caching = true;
$smarty->cache_lifetime = 120;

$smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill",true);
$smarty->assign("FirstName",array("John","Mary","James","Henry"));
$smarty->assign("LastName",array("Doe","Smith","Johnson","Case"));
$smarty->assign("Class",array(array("A","B","C","D"), array("E", "F", "G", "H"),
	  array("I", "J", "K", "L"), array("M", "N", "O", "P")));

$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
	  array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));

$smarty->assign("option_values", array("NY","NE","KS","IA","OK","TX"));
$smarty->assign("option_output", array("New York","Nebraska","Kansas","Iowa","Oklahoma","Texas"));
$smarty->assign("option_selected", "NE");

$smarty->display('index.tpl');
*/
?>